package IOStreamStudy.charSetQuestion;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

/**
 * 文件制定编码写入
 * */

public class CharSetWriteDemo {

    public static void main(String[] args)  throws IOException {
        String filePath = "D:\\all_projects\\java_projects\\java_ij\\springMVC\\NetWork\\src\\cn" +
                "\\usts\\edu\\IOStreamStudy\\charSetQuestion\\b.txt";
        FileOutputStream fileOutputStream = new FileOutputStream(filePath);

        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "gbk");

        BufferedWriter bufferedWriter = new BufferedWriter(outputStreamWriter);
        bufferedWriter.write("利用OutputStreamWriter,和InputStreamReader读写文件,防止文件出现编码问题");
        bufferedWriter.close();
    }
}
